class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2024-05-20",
      revision: "094f6f9304e853dc52fa71f2cec8423ea3ccb3cd"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "be59835bf50ee5c82fb30bae5c85fa9fb964c824aab4c2ed6ffc50bc58cd6b10"
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "6b33051056b51a5243029bbc8c4aa3788c014c9b4ad8dacae3bd93024bad2531"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "2570a0196f358a710b2f474d586b220fc78dcfcb2eab514c2dcbbc2a452c9687"
    sha256 cellar: :any_skip_relocation, sonoma:         "f9e716ec4574379d4baa8bbe21984f6d9defb150ec49c82393e77a183b0ab5dc"
    sha256 cellar: :any_skip_relocation, ventura:        "b0f1bb0403948878d3b1f174c21e1bc54692c1e4be0171d781ed9fee3f4054d9"
    sha256 cellar: :any_skip_relocation, monterey:       "edfbd846fde33965d99d5a9e60664d7beae37fd6bc14af5319ec1768cae89330"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "335fadc77d6517d804678918486f269e0a7e10b1a1656ba9a343aff325f01fc9"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
